# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: http://doc.scrapy.org/en/latest/topics/item-pipeline.html
import datetime


class TourCommentCrawlerPipeline(object):
    def process_item(self, item, spider):
        item = dict(item)
        area = item.pop("area")
        category = item.pop("category")
        score = item.pop("score")
        key = area + ":" + category + ":" + item["tour_id"]
        total_key = area + ":" + category + ":0"
        spider.server.zadd(key, score, item)
        spider.server.zadd(total_key, score, item)
        return item
